﻿using System;
using System.Collections.Generic;

using Apache.Cassandra;

namespace RexToy.Cassandra.Meta
{
    internal class ColumnInfo
    {
        private ColumnDef _def;
        private ColumnFamilyInfo _cfInfo;
        internal ColumnInfo(ColumnDef def, ColumnFamilyInfo cfInfo)
        {
            def.ThrowIfNullArgument("def");
            cfInfo.ThrowIfNullArgument("cfDef");
            _def = def;
            _cfInfo = cfInfo;
        }

        public string IndexName
        {
            get { return _def.Index_name; }
        }

        public string ValidationClass
        {
            get { return _def.Validation_class; }
        }

        public IMarshal Validation
        {
            get
            {
                return MarshalFactory.CreateMarshal(_def.Validation_class);
            }
        }

        public object Name//Extend:generic type T
        {
            get
            {
                return _cfInfo.Comparator.GetData(_def.Name);
            }
        }

        public IReadOnlyDictionary<string, string> Options
        {
            get { return _def.Index_options; }
        }

        public IndexType IndexType
        {
            get { return (IndexType)_def.Index_type; }
        }
    }
}
